package com.powernode.controller;

import com.powernode.common.ResultJson;
import com.powernode.service.FileService;
import io.minio.errors.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * @Description TODO
 * @Date 2022/4/7 12:29
 * @Version 1.0
 */
@RestController
@RequestMapping("/pmsFile")
public class FileController {
    @Resource
    private FileService fileService;

    @PostMapping("/upload")
    ResultJson<String> upload(MultipartFile file,String bucket) throws IOException, InvalidKeyException, InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException, ServerException, ErrorResponseException, XmlParserException, InternalException {
        return ResultJson.success(fileService.upload(file,bucket));
    }
}
